package path;
import geom.*;
import processing.core.*;
import processing.opengl.*;
import shapes.Cross;
import util.*;

public class DrawLinePath implements PathDrawer {
	int thickness;
	Color stroke;
	Vector prev;
	boolean firstCall;
	
	public DrawLinePath(int thickness, Color stroke) {
		this.thickness = thickness;
		this.stroke = stroke;
		prev = new Vector();
		firstCall = true;
	}

	public void drawPath(Path path, PApplet pa) {
		pa.noFill();
		stroke.stroke(pa);
		pa.beginShape(/*PApplet.LINE_STRIP*/);
		
		for(int i = 0; i < path.keyFrames.size(); i++){
			
			Vector v = path.getKeyFrameByIndex(i).getPosition();
			
			if(!v.equalTo(prev) || firstCall){
				pa.vertex(v.x, v.y, v.z);

			}
			prev = v.getCopy();
			if(firstCall) firstCall = false;
		}
		pa.endShape();
		/*
		for(int i = 0; i < path.keyFrames.size(); i++){
			Vector v = path.getKeyFrameByIndex(i).getPosition();
			pa.pushMatrix();
			pa.translate(v.x, v.y, v.z);
			if(path.getKeyFrameByIndex(i).original)
				Cross.draw(pa, 5, new Color(0, 0, 255));
			else
				Cross.draw(pa, 3, new Color(0, 255, 0));
			pa.popMatrix();
		}
		*/
	}

	public void keyAdded(Path p) {
		// TODO Auto-generated method stub
		
	}
	
	public void keysAdded(Path p, int amount) {
		// TODO Auto-generated method stub
		
	}

	public void keyRemoved(Path p, int i) {
		// TODO Auto-generated method stub
		
	}

}
